package com.yh.patterns.factory.simple_factory.simple_factory_nvwa;

import com.yh.patterns.factory.simple_factory.simple_factory_nvwa.impl.Man;
import com.yh.patterns.factory.simple_factory.simple_factory_nvwa.impl.Woman;

/**
 * @Auther:云尚学Java
 */
public class Nvwa {
    public Person createPerson(String type){
        //1.声明Person类型的变量，根据不同类型创建不同的person子类对象
        Person person=null;
        if("M".equals(type)){
            person=new Man();
        }else if("W".equals(type)){
            person=new Woman();
        }else {


            throw new RuntimeException("对不起，您不能这样造人");
        }
        return person;
    }
}
